package com.yf1706.configuration;

import java.util.HashSet;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ConversionServiceFactoryBean;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.converter.Converter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.yf1706.converter.StringToDate;


/**
 * 配置全局日期转换器
 */
@Configuration
public class GolbalConverter extends WebMvcConfigurerAdapter   {
	
	@Autowired
	/**
	 * 全局转换器
	 * @return
	 */
	
	private ConversionService getConversionService() {
		ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
		Set<Converter> converters = new HashSet<Converter>();
		converters.add(new StringToDate());
		factoryBean.setConverters(converters);
		return factoryBean.getObject();
	}
}


